package com.mingyizhudao.app.view.mine.adpter;

import java.text.SimpleDateFormat;
import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import com.dixiang.framework.utils.Utils;
import com.mingyizhudao.app.R;
import com.mingyizhudao.app.common.BaseViewHolder;
import com.mingyizhudao.app.utils.CommonUtils;
import com.mingyizhudao.app.view.mine.bean.OrderItemEntity;

public class OrderItemAdpter extends ArrayAdapter<OrderItemEntity>{
    private Context context;
    LayoutInflater inflater;
	public OrderItemAdpter(Context context) {
		super(context, android.R.layout.simple_list_item_1);
        this.context = context;
        this.inflater = LayoutInflater.from(context);
	}
	
	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
		
		OrderHolder holder = null;
		 if (convertView == null) {
	            convertView = inflater.inflate(R.layout.lv_item_order, null);
	            holder = new OrderHolder(convertView);
	            convertView.setTag(holder);
	        } else {
	            holder = (OrderHolder) convertView.getTag();
	        }
	        holder.populateView(position, getItem(position));
		return convertView;
	}
	
	
	class OrderHolder extends BaseViewHolder<OrderItemEntity>{
		
		private TextView tv_orderid ,tv_orderdoctor ,tv_orderhospital;
		
		public OrderHolder(View view) {
			super(view);
			tv_orderid = (TextView)view.findViewById(R.id.tv_orderid);
			tv_orderdoctor = (TextView)view.findViewById(R.id.tv_orderdoctor);
			tv_orderhospital = (TextView)view.findViewById(R.id.tv_orderhospital);
		}

		@Override
		public void populateView(int position, OrderItemEntity item) {
			tv_orderid.setText(item.getRefNo());
			String doctorName = Utils.isStringEmpty(item.getExpertName()) ? "未填写" : item.getExpertName();
			tv_orderdoctor.setText(doctorName);
			//tv_orderhospital.setText(item.getHpShortName()+"/"+item.getHpShortName());
			if( item.getHpName()==null|| (item.getHpName()!=null&&(item.getHpName().equals( "null" )||item.getHpName().equals( "" ))))
			{
				tv_orderhospital.setText(item.getHpDeptName());//简称
			}else {
				tv_orderhospital.setText(item.getHpName()+"/"+item.getHpDeptName());//简称
			}
		}
		
	}

}
